AnnieRoot.gresult=AnnieRoot.gresult||{};
gresult.Gresult=function(){
	var s = this;
	annie.MovieClip.call(s);
	/*_a2x_need_start*/s.playAgain_btn=null;/*_a2x_need_end*/
	annie.initRes(s,"gresult","Gresult");
	//your code here
	var isBtnCanClick = true;
	s.addEventListener(annie.Event.ADD_TO_STAGE, function (e) {
		s.isAddChooesGift = false;
		//TODO 解决华为点击Bug
		showDivGameBtn(false);

		s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = false;
		if (s.orderFrom == 'gameOver') {
			s.gotoAndPlay(2);
		} else if (s.orderFrom == 'myPrize') {
			s.gotoAndPlay('start');
		} else {
			s.gotoAndPlay(2);
		}
	});
	s.addEventListener(annie.Event.END_FRAME, function (e) {
		if (window.navigator.onLine == false) {
			alert('网络故障，请确保您的网络通畅！');
			return;
		}
		if (s.orderFrom == 'gameOver') {
			if (gameGlobalData.chooesGiftData && gameGlobalData.chooesGiftData.length > 0 && gameGlobalData.resultType == 3) {
				//达到获奖条件
				s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = false;
				setTimeout(function () {
					annie.globalDispatcher.dispatchEvent('addChooesGiftBox');//
					s.isAddChooesGift = true;
				}, 800)
			} else {
				//没有达到获奖条件
				s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = true;
			}
			// trace('end');
		} else {
			s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = true;
		}
	});
	/*获取到数据,如果没有添加礼物选择弹框，就添加*/
	annie.globalDispatcher.addEventListener('initChooesGiftData', function (e) {
		if (!s.isAddChooesGift) {
			if (s.orderFrom == 'gameOver') {
				if (gameGlobalData.chooesGiftData && gameGlobalData.chooesGiftData.length > 0 && gameGlobalData.resultType == 3) {
					//达到获奖条件
					s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = false;
					setTimeout(function () {
						annie.globalDispatcher.dispatchEvent('addChooesGiftBox');//
						s.isAddChooesGift = true;
					}, 800)
				} else {
					//没有达到获奖条件
					s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = true;
				}
				// trace('end');
			} else {
				s.playAgain_btn.mouseEnable = s.playAgain_btn.mouseChildren = true;
			}
		}
	});
	/*再玩一次*/
	s.playAgain_btn.addEventListener(annie.MouseEvent.CLICK, function (e) {
		if (window.navigator.onLine == false) {
			alert('网络故障，请确保您的网络通畅！');
			return;
		}
		isBtnCanClick = false;
		s.play(false);
		if (!s.hasEventListener(annie.Event.CALL_FRAME)) {
			s.addEventListener(annie.Event.CALL_FRAME, s.cf = function (e) {
				// trace(e.data.frameName);
				if (e.data.frameName == 'backEndPos') {
					s.removeEventListener(annie.Event.CALL_FRAME, s.cf);
					s.parent.removeChild(s);
					isBtnCanClick = true;
					gameGlobalData.initGameData.code=true;
					if (gameGlobalData.initGameData.gamesum > -1 && gameGlobalData.initGameData.code) {
						// annie.globalDispatcher.dispatchEvent('gameStart');//游戏开始
						annie.globalDispatcher.dispatchEvent('setGameInitDataToStartGame');//游戏开始
					} else {
						//用户游戏次数用完，弹出游戏次数不足弹框
						annie.globalDispatcher.dispatchEvent('userNotEnoughGameTimes');
					}
				}
			})
		}
	});
};
A2xExtend(gresult.Gresult,annie.MovieClip);
gresult.Gresult.prototype.isAddChooesGift = false;
gresult.Gresult.prototype.orderFrom = 'gameOver';
